#include <bits/stdc++.h>
#define ll long long
#define N 100010
using namespace std;

class AC
{
public:
    AC(){}
    void insert(string&s)
    {
        int p = 0;
        for(int i = 0;i<s.size();++i)
        {
            int c = s[i]-'a';
            if(tr[p][c]==0)
            {
                tr[p][c] = ++cnt;
            }
            p = tr[p][c];
        }
        exist[p] = true;
    }
    bool find(string&s)
    {
        int p = 0;
        for(int i = 0;i<s.size();++i)
        {
            int c = s[i]-'a';
            if(tr[p][c]==0)
            {
                return false;
            }
            p = tr[p][c];
        }
        return exist[p];
    }
    void bulid()
    {
        for(int i = 0;i<26;++i)
        {
            if(tr[0][i])
            {
                q.push(tr[0][i]);
            }
        }
        while(!q.empty())
        {
            int u = q.front();
            q.pop();
            for(int i = 0;i<26;++i)
            {
                if(tr[u][i])
                {
                    tr[tr[u][i]]
                }
            }
        }
    }
private:
    int cnt = 0;
    tr[N][26];
    bool exist[N];
    queue<int> q;
};

int main()
{
    return 0;
}
